Java
The following Java libraries are required for proper working of the examples below:
http://commons.apache.org/codec/
partner10.createKey()
import java.util.Hashtable;
import java.util.Vector;
import org.apache.xmlrpc.XmlRpcClient;
public class CreateKeyExample
{
private static final String KA_SERVICE = "https://ka.demo.plesk.com:7050";
private static final String REMOTE_API_LOGIN = "API_LOGIN";
private static final String REMOTE_API_PASSWORD = "API_PASSWORD";
public static void main( String[] args ) throws Exception
{
//create xml-rpc client instance point to KA service
XmlRpcClient xmlRpcClient = new XmlRpcClient(KA_SERVICE);
//prepare vector for passing arguments
Vector methodArguments = new Vector();
//create authInfo structure and pass as method argument
Hashtable authInfo = new Hashtable();
authInfo.put( "login",API_LOGIN);
authInfo.put( "password",API_PASSWORD);
methodArguments.add(authInfo);
//create serverInfo structure and pass as method argument
Vector ipsVector = new Vector();
ipsVector.add( "192.168.0.0" );
Hashtable serverInfo = new Hashtable();
serverInfo.put("ips",ipsVector);
methodArguments.add( serverInfo );
//pass client login
methodArguments.add( "CLIENT_LOGIN" );
//keytype api constant name
methodArguments.add( "PLESK_8" );
//create vector of upgrade plans constant and pass as argument
Vector features = new Vector();
features.add( "30_DOMAINS" );
features.add( "1YR_PREMIUM_SUPPORT_PACK" );
methodArguments.add( features );
//Invoke method
Hashtable invocationResult = (Hashtable)xmlRpcClient.execute("partner10.createKey",methodArguments);
System.out.println(invocationResult);
}
}
partner10.upgradeKey()
import java.util.Hashtable;
import java.util.Vector;
import org.apache.xmlrpc.XmlRpcClient;
public class UpgradeKeyExample
{
private static final String KA_SERVICE = "https://ka.demo.plesk.com:7050";
private static final String REMOTE_API_LOGIN = "API_LOGIN";
private static final String REMOTE_API_PASSWORD = "API_PASSWORD";
public static void main( String[] args ) throws Exception
{
//create xml-rpc client instance point to KA service
XmlRpcClient xmlRpcClient = new XmlRpcClient(KA_SERVICE);
//prepare vector for passing arguments
Vector methodArguments = new Vector();
//create authInfo structure and pass as method argument
Hashtable authInfo = new Hashtable();
authInfo.put( "login",API_LOGIN);
authInfo.put( "password",API_PASSWORD);
methodArguments.add(authInfo);
//Key number to be upgraded
methodArguments.add( "PLSK.12345678.1234" );
//Upgrade plan constant to be applied
methodArguments.add( "100_DOMAINS_TO_UNLIMITED_DOMAINS" );
//Invoke method
Hashtable invocationResult = (Hashtable)xmlRpcClient.execute("partner10.upgradeKey",methodArguments);
System.out.println(invocationResult);
}
}